#include <assert.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, const char **argv) {
	if (argc != 2) {
		fprintf(stderr, "usage: x86_64-deconstruct-vaddr <vaddr>\n");
		return 1;
	}
	assert(sizeof(unsigned long long) == sizeof(size_t));
	unsigned long long addr = strtoull(argv[1], NULL, 0);
	printf("pml4e %i\n", (addr & 0x0000ff8000000000) >> 39);
	printf("pdpte %i\n", (addr & 0x0000007fc0000000) >> 30);
	printf("pde %i\n", (addr & 0x000000003fe00000) >> 21);
	printf("pte %i\n", (addr & 0x00000000001ff000) >> 12);
	printf("bi %i\n", (addr & 0x0000000000000fff) >> 0);
}
